package org.mzx.shortLink.VIP.controller;

import lombok.RequiredArgsConstructor;
import org.mzx.shortLink.VIP.dto.request.payVipOrRenewalReq;
import org.mzx.shortLink.VIP.service.TVipService;
import org.mzx.shortLink.starter.convention.Result.Result;
import org.mzx.shortLink.starter.web.Results;
import org.springframework.web.bind.annotation.*;

/**
 * @author mazhenxi
 * @date 2025/4/27
 */
@RestController
@RequiredArgsConstructor
public class TVipController {

    private final TVipService service;

    /**
     * 开通或续费VIP
     * @param requestParam
     * @return
     */
    @PostMapping("/api/short-link/vip/v1/payVipOrRenewal")
    public Result payVipOrRenewal(@RequestBody payVipOrRenewalReq requestParam) {
        service.payVipOrRenewal(requestParam);
        return Results.success();
    }

    /**
     * 检查一个用户是不是VIP
     * @param userName
     * @return
     */
    @GetMapping("/api/short-link/vip/check")
    public Result<Boolean> check(@RequestParam("userName") String userName) {
        return Results.success(service.check(userName));
    }
}
